/**
 * 部门开窗-多选
 * @author shixc
 * @date 2019/03/14
 */
define(function () {

    var self,
        app = win.app,
        vueData = {
            tableData: [],
            count: 0,
            /*limit: 10,*/
            keyword: ''
        },
        page = 1,
        cb
    ;

    app.newModule({
        init: function () {
            self = this;
            self._super({
                _tag: 'common_open_multi_xsqd'
            }, win);
        },
        queryDatas: function () {
            app.ajax({
                xurl: 'sys/notice/getGwaeList',
                xdata: {
                    page: page,
                    /*limit: vueData.limit,*/
                    keyword: vueData.keyword
                },
                cb: function (result) {
                    if (result.ok) {
                        vueData.tableData.pushArray(result.data.data, true);
                        vueData.count = result.data.data.length;
                    }
                }
            });
        },

        _call: function (obj) {
            cb = obj.cb;
            vueData.keyword = '';
            self.queryDatas();
        },

        _ready: function () {
            new Vue({
                el: '#common_open_multi_xsqd',
                data: vueData,
                methods: {
                    selectRow: function (inx, row) {
                        app.log(inx, row);
                        cb(row);
                        layer.close(layer.index);
                    },
                    handleSizeChange: function (val) {
                        //console.log(`每页 ${val} 条`);
                    },
                    handleCurrentChange: function (val) {
                        page = val;
                        self.queryDatas();
                    },
                    queryDatas: function () {
                        page = 1;
                        self.queryDatas();
                    },
                    cancle: function (rows) {
                        layer.close(layer.index);
                    },
                    handleSelectionChange: function (val) {
                        this.multipleSelection = val;
                        //layer.close(layer.index);
                    },
                    save: function () {
                        cb(this.multipleSelection);
                        this.multipleSelection = [];
                        layer.close(layer.index);
                    }
                },
                created: function () {
                    self._setEleIsReady('common_open_multi_xsqd');
                }
            });
        },
        _lazy: function () {
            this._super();
        }
    });

});